<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .active1{
            background-image: url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2F1113%2F060120105F7%2F200601105F7-1-1200.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1647595321&t=213e1ba3baca6fa3399a607d249db0bd);
            background-size: 100vw 100vh;
        }

        .active2{
            background-image: url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic%2F26%2Fc8%2F69%2F26c869bc8428113a454b0207e42f339f.jpg&refer=http%3A%2F%2Fup.enterdesk.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1647595321&t=93b44ed578b4fe7721f43b19700017a3);
            background-size: 100vw 100vh;
        }
    </style>
</head>
<body>
    <button>按钮一</button><button>按钮二</button>
    <script>
        var btns = document.querySelectorAll("button");
        // btns[0].onclick = function(){
        //     document.body.className = "active1";
        // }
        // btns[1].onclick = function(){
        //     document.body.className = "active2";
        // }

        for(let i=0;i<btns.length;i++){
            btns[i].onclick = function(){
                // console.log(i);
                document.body.className = `active${1+i}`;
            }
        }

    </script>
</body>
</html>